home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12873 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  48 lines

  1. Path: magnus.acs.ohio-state.edu!mail-news-gateway
  2. From: tsv@cs.umanitoba.ca (R.Ganesan)
  3. Newsgroups: comp.lang.c++
  4. Subject: gcc does not inline template member functions!
  5. Date: 22 Mar 1996 00:10:19 -0500
  6. Organization: The Ohio State University
  7. Sender: root@magnus.acs.ohio-state.edu
  8. Message-ID: <199603220508.AAA13769@polarmet.mps.ohio-state.edu>
  9. Reply-To: tsv@cs.umanitoba.ca
  10. NNTP-Posting-Host: charm.magnus.acs.ohio-state.edu
  11.  
  12.  
  13. Hi,
  14.  
  15.     I was surprised to find that gcc does not inline template member
  16. functions. It doesn't inline function templates either. I have checked the
  17. assembler output of gcc-2.7.2 (with -O6) on a DEC Alpha running OSF/1 3.0, 
  18. on an 486 PC running NetBSD 1.0,  and gcc-2.6.3 on a Sun3.
  19.  
  20.     Check the assembler output of the following trivial program and you'll
  21. see a function call for (mangled) sum. This seems to be a big drawback in
  22. using templates with gcc. Will 2.8.0 do inlining for templates? Please CC
  23. replies to me. Thank you.
  24.  
  25. ----
  26.  
  27. template <class T>
  28. inline int
  29. sum(T a, T b) { return a + b; }
  30.  
  31. int 
  32. main()
  33. {
  34.     sum(1, 2);
  35. }
  36.  
  37. -- R. Ganesan
  38.  
  39. ---
  40. -----------------------------------------------------------------------------
  41. | R. Ganesan,           |           Email: tsv@cs.umanitoba.ca            |
  42. | M.Tech (CSE),          |         Specify subject as: To Ganesan          |
  43. | IIT-Kanpur, India       |       (This is actually a proxy address :-)        |
  44. -----------------------------------------------------------------------------
  45.  
  46.  
  47.  
  48.